$(function(){
    $("#loginButton").click(function(){
        if($("#phone").val()!="" && $("#pwd").val()!=""){
            $.ajax({
                type: "post",
                url: "../user/userLogin.json",
                data: {"phone": $("#phone").val(),"pwd":$("#pwd").val()},
                dataType:"json",
                success: function (result) {
                    if (result.defult == "true") {
                        //跳转到主页面
                        location.href="../jsp/index.jsp";
                    }else {
                        var layer = layui.layer
                            , form = layui.form;
                        layer.msg('账号或密码错误');
                        $("#phone").val("");
                        $("#pwd").val("");
                        return;
                    }
                }
            })
        }else{
            var layer = layui.layer
                ,form = layui.form;
            layer.msg('账号或密码不能为空！');
            return;
        }
    })
})